<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>微信公众平台</title>

<script type="text/javascript">
function loadResponse()
{
	var uname = document.getElementById("username").value;
	var passwd = document.getElementById("password").value;
	if (uname.length == 0 || passwd.length == 0){
		 document.getElementById("DivRes").innerHTML = "username or password not correct.";
		 return;
	}
		
    var xmlhttp;
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200){
        	if (xmlhttp.responseText.length != 0){
                document.getElementById("DivRes").innerHTML=xmlhttp.responseText;
        	} else {
        		window.location.href = "main.jsp";
        	}
        }
    }
    
    var url = "<%=request.getContextPath()%>/Login?username=" + uname + "&password=" + passwd;
    document.getElementById("DivRes").innerHTML = url;
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
}
</script>

</head>

<body>
  <br/><br/><hr/><br/><br/>
  <table border="1" style="margin:auto">
  <tr>
      <td><img src="<%=request.getContextPath()%>/pic/login.jpg"></td>
  </tr>
  <tr>
      <td>
          <table width = "100%" height = "100%" border = "0px">
			<tr><td>用户名：</td><td><input type = "text" id="username" name = "username"/></td></tr>
			<tr><td>密　码：</td><td><input type = "password" id="password" name = "password"></td></tr>
			<tr><td colspan = "2" >
			    <button type = "button" style="width:100px;"  onclick="loadResponse()">登陆</button>　
			    <button type = "button" style="width:100px;">重新填写</button>
			</td></tr>
			<tr><td colspan = "2">
			<a href = "#">找回密码</a>　　　
			<a href = "#">注册用户</a>
			</td></tr>
			<tr><td colspan = "2">
			<div id="DivRes"></div>　　
			</td></tr>			
		  </table>
      </td>
  </tr>
  </table>
  <br/>
      <div id="DivRes"></div>
  <br/><br/><hr/><br/><br/>
</body>
</html>

